package com.shenmazg6.controller;

import com.shenmazg6.service.TbOrderService;
import com.shenmazg6.utils.ResultResponse;
import com.shenmazg6.vo.BuyOrderVo;
import com.shenmazg6.vo.OrderNoInfoVo;
import com.shenmazg6.vo.PageInfoVo;
import com.shenmazg6.vo.WxPayOrderVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 军哥
 * @version 1.0
 * @description: TbOrderController
 * @date 2022/12/20 11:04
 */

@RestController
@Slf4j
@RequestMapping(value = "/order")
public class TbOrderController {

    @Autowired
    TbOrderService tbOrderService;

    @PostMapping(value = "/buyOrder")
    public ResultResponse buyOrder(@RequestBody BuyOrderVo buyOrderVo) {
        return tbOrderService.buyOrder(buyOrderVo);
    }

    @PostMapping(value = "/list")
    public ResultResponse list(@RequestBody PageInfoVo pageInfoVo) {
        return tbOrderService.listByPage(pageInfoVo);
    }

    /**
     * 获取订单编号接口
     * @return
     */
    @PostMapping(value = "/getOrderNo")
    public ResultResponse getOrderNo() {
        return tbOrderService.getOrderNo();
    }

    /**
     * 获取微信支付二维码接口
     * @param wxPayOrderVo
     * @return
     */
    @PostMapping(value = "/getPayCode")
    public ResultResponse getPayCode(@RequestBody WxPayOrderVo wxPayOrderVo) {
        return tbOrderService.getPayCode(wxPayOrderVo);
    }

    @PostMapping(value = "/getAlipayCode")
    public ResultResponse getAlipayCode(@RequestBody WxPayOrderVo wxPayOrderVo) {
        return tbOrderService.getAlipayCode(wxPayOrderVo);
    }

    /**
     * 获取订单支付状态
     * @param orderNoInfoVo
     * @return
     */
    @PostMapping(value = "/getOderState")
    public ResultResponse getOderState(@RequestBody OrderNoInfoVo orderNoInfoVo) {
        return tbOrderService.getOderState(orderNoInfoVo);
    }

    @PostMapping(value = "/changeOrderState")
    public ResultResponse changeOrderState(@RequestBody OrderNoInfoVo orderNoInfoVo) {
        return tbOrderService.changeOrderState(orderNoInfoVo);
    }

}
